package com.zkhz.base.domian.mapper;

import com.zkhz.base.domian.dto.MyUserDTO;
import com.zkhz.base.domian.entity.MyUser;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class MyUserDTOMapper {

    private MyUserDTOMapper() {
        // 无需实现
    }

    public static List<MyUser> toMyUserList(List<MyUserDTO> myUserDTOList) {
        if (myUserDTOList == null) {
            return Collections.emptyList();
        }
        List<MyUser> myUserList = new ArrayList<>();
        for (MyUserDTO myUserDTO : myUserDTOList) {
            myUserList.add(toMyUser(myUserDTO));
        }
        return myUserList;
    }

    public static MyUser toMyUser(MyUserDTO myUserDTO) {
        if (myUserDTO == null) {
            return null;
        }
        MyUser myUser = new MyUser();
        myUser.setUsername(myUserDTO.getUsername());
        myUser.setPassword(myUserDTO.getPassword());
        myUser.setSchrodingerCat(myUserDTO.getSchrodingerCat());
        myUser.setName(myUserDTO.getName());
        myUser.setTitle(myUserDTO.getTitle());
        myUser.setAge(myUserDTO.getAge());
        myUser.setStatus(myUserDTO.getStatus());
        myUser.setId(myUserDTO.getId());
        myUser.setCreateTime(myUserDTO.getCreateTime());
        myUser.setUpdateTime(myUserDTO.getUpdateTime());
        myUser.setCreateUser(myUserDTO.getCreateUser());
        myUser.setUpdateUser(myUserDTO.getUpdateUser());
        myUser.setDeleted(myUserDTO.getDeleted());
// Not mapped TO fields:
// gender
        return myUser;
    }

    public static List<MyUserDTO> toMyUserDTOList(List<MyUser> myUserList) {
        if (myUserList == null) {
            return Collections.emptyList();
        }
        List<MyUserDTO> myUserDTOList = new ArrayList<>();
        for (MyUser myUser : myUserList) {
            myUserDTOList.add(toMyUserDTO(myUser));
        }
        return myUserDTOList;
    }

    public static MyUserDTO toMyUserDTO(MyUser myUser) {
        if (myUser == null) {
            return null;
        }
        MyUserDTO myUserDTO = new MyUserDTO();
        myUserDTO.setUsername(myUser.getUsername());
        myUserDTO.setPassword(myUser.getPassword());
        myUserDTO.setSchrodingerCat(myUser.getSchrodingerCat());
        myUserDTO.setName(myUser.getName());
        myUserDTO.setTitle(myUser.getTitle());
        myUserDTO.setAge(myUser.getAge());
        myUserDTO.setStatus(myUser.getStatus());
        myUserDTO.setId(myUser.getId());
        myUserDTO.setCreateTime(myUser.getCreateTime());
        myUserDTO.setUpdateTime(myUser.getUpdateTime());
        myUserDTO.setCreateUser(myUser.getCreateUser());
        myUserDTO.setUpdateUser(myUser.getUpdateUser());
        myUserDTO.setDeleted(myUser.getDeleted());
// Not mapped FROM fields:
// gender
        return myUserDTO;
    }

    public static MyUser copyToMyUser(MyUserDTO myUserDTO, MyUser myUser) {
        myUser.setUsername(myUserDTO.getUsername());
        myUser.setPassword(myUserDTO.getPassword());
        myUser.setSchrodingerCat(myUserDTO.getSchrodingerCat());
        myUser.setName(myUserDTO.getName());
        myUser.setTitle(myUserDTO.getTitle());
        myUser.setAge(myUserDTO.getAge());
        myUser.setStatus(myUserDTO.getStatus());
        return myUser;
    }
}
